import type { ElementHiderRuleConfig } from '../../../types/constants'
import { ElementSelectorCompoundQueryScope, ElementSelectorPosition, ElementSelectorType } from '../../../types/constants'
import { ELEMENT_IDENTIFIER_CONFIG } from '../../service/element_identifier/types'

export const CSDN_WEB_ELEMENT_CONFIG: ElementHiderRuleConfig = {
  [ELEMENT_IDENTIFIER_CONFIG.default.header.id]: {
    hide: true,
    selectorType: ElementSelectorType.Id,
    selector: '#toolbarBox',
    position: ElementSelectorPosition.TopCenter,
    effectToc: true,
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.leftAside.id]: {
    hide: true,
    selectorType: ElementSelectorType.Class,
    selector: '.blog_container_aside',
    position: ElementSelectorPosition.MiddleLeft,
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.profile.id]: {
    hide: true,
    selectorType: ElementSelectorType.Id,
    selector: '#asideProfile',
    position: ElementSelectorPosition.MiddleLeft,
  },
  [ELEMENT_IDENTIFIER_CONFIG.ad.remunerationAd.id]: {
    hide: true,
    selectorType: ElementSelectorType.Class,
    selector: '.swiper-remuneration-container',
    position: ElementSelectorPosition.MiddleLeft,
  },
  [ELEMENT_IDENTIFIER_CONFIG.blog.hotArticle.id]: {
    hide: true,
    selectorType: ElementSelectorType.Complex,
    selector: '#asideHotArticle:has(h3[data-title=\'热门文章\'])',
    position: ElementSelectorPosition.MiddleLeft,
    clearChildStyles: true,
  },
  [ELEMENT_IDENTIFIER_CONFIG.blog.articlePrevious.id]: {
    hide: true,
    selectorType: ElementSelectorType.Class,
    selector: '.article-previous',
    position: ElementSelectorPosition.MiddleLeft,
  },
  [ELEMENT_IDENTIFIER_CONFIG.blog.latestComment.id]: {
    hide: true,
    selectorType: ElementSelectorType.Id,
    selector: '#asideNewComments',
    position: ElementSelectorPosition.MiddleLeft,
  },
  [ELEMENT_IDENTIFIER_CONFIG.blog.everyoneWatching.id]: {
    hide: true,
    selectorType: ElementSelectorType.Complex,
    selector: '#asideHotArticle:has(h3[data-title=\'大家在看\'])',
    position: ElementSelectorPosition.MiddleLeft,
    clearChildStyles: true,
  },
  [ELEMENT_IDENTIFIER_CONFIG.blog.latestArticle.id]: {
    hide: true,
    selectorType: ElementSelectorType.Complex,
    selector: '#asideArchive:has(h3[data-title=\'最新文章\'])',
    position: ElementSelectorPosition.MiddleLeft,
    clearChildStyles: true,
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.loginModal.id]: {
    hide: true,
    selectorType: ElementSelectorType.Class,
    selector: '.passport-login-container',
    position: ElementSelectorPosition.MiddleCenter,
  },
  [ELEMENT_IDENTIFIER_CONFIG.blog.recommendColumn.id]: {
    hide: true,
    selectorType: ElementSelectorType.Id,
    selector: '#blogColumnPayAdvert',
    position: ElementSelectorPosition.MiddleCenter,
  },
  [ELEMENT_IDENTIFIER_CONFIG.blog.recommendCommunity.id]: {
    hide: true,
    selectorType: ElementSelectorType.Id,
    selector: '#blogHuaweiyunAdvert',
    position: ElementSelectorPosition.MiddleCenter,
  },
  [ELEMENT_IDENTIFIER_CONFIG.blog.runnerBox.id]: {
    hide: true,
    selectorType: ElementSelectorType.Class,
    selector: '.runner-box',
    position: ElementSelectorPosition.MiddleCenter,
  },
  [ELEMENT_IDENTIFIER_CONFIG.ai.aiAbstract.id]: {
    hide: true,
    selectorType: ElementSelectorType.Class,
    selector: '.ai-abstract-box',
    position: ElementSelectorPosition.MiddleCenter,
  },
  [ELEMENT_IDENTIFIER_CONFIG.blog.officialTocTwo.id]: {
    hide: true,
    selectorType: ElementSelectorType.Mix,
    selector: 'article .toc',
    nameZh: '文章目录（类型一）',
    position: ElementSelectorPosition.MiddleCenter,
  },
  [ELEMENT_IDENTIFIER_CONFIG.blog.officialTocThree.id]: {
    hide: true,
    selectorType: ElementSelectorType.Id,
    selector: '#main-toc',
    nameZh: '文章目录（类型二）',
    position: ElementSelectorPosition.MiddleCenter,
    compoundOptions: {
      attr: 'name',
      value: 'tableOfContents',
      scope: ElementSelectorCompoundQueryScope.Siblings,
    },
  },
  [ELEMENT_IDENTIFIER_CONFIG.blog.articleHr.id]: {
    hide: false,
    selectorType: ElementSelectorType.Mix,
    selector: 'article hr',
    position: ElementSelectorPosition.MiddleCenter,
  },
  [ELEMENT_IDENTIFIER_CONFIG.ai.aiCode.id]: {
    show: false,
    hide: true,
    selectorType: ElementSelectorType.Mix,
    selector: 'button.btn-code-notes',
    position: ElementSelectorPosition.MiddleCenter,
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.rightAside.id]: {
    hide: true,
    selectorType: ElementSelectorType.Id,
    selector: '#rightAside',
    position: ElementSelectorPosition.MiddleRight,
  },
  [ELEMENT_IDENTIFIER_CONFIG.blog.officialToc.id]: {
    hide: true,
    selectorType: ElementSelectorType.Id,
    selector: '#groupfile',
    position: ElementSelectorPosition.MiddleRight,
  },
  [ELEMENT_IDENTIFIER_CONFIG.ad.contentAd.id]: {
    hide: true,
    selectorType: ElementSelectorType.Id,
    selector: '#recommendAdBox',
    position: ElementSelectorPosition.MiddleRight,
  },
  [ELEMENT_IDENTIFIER_CONFIG.blog.categoryColumn.id]: {
    hide: true,
    selectorType: ElementSelectorType.Complex,
    selector: '.kind_person:has(h3[data-title=\'分类专栏\'])',
    position: ElementSelectorPosition.MiddleRight,
    clearChildStyles: true,
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.rightAsideToolbar.id]: {
    hide: true,
    selectorType: ElementSelectorType.Class,
    selector: '.csdn-side-toolbar',
    position: ElementSelectorPosition.MiddleRight,
  },
  [ELEMENT_IDENTIFIER_CONFIG.ad.adBar.id]: {
    hide: true,
    selectorType: ElementSelectorType.Id,
    selector: '#footerRightAds',
    position: ElementSelectorPosition.BottomLeft,
  },
  [ELEMENT_IDENTIFIER_CONFIG.ad.adBarTwo.id]: {
    hide: true,
    selectorType: ElementSelectorType.Class,
    selector: '.wwads-sticky',
    position: ElementSelectorPosition.BottomLeft,
  },
  [ELEMENT_IDENTIFIER_CONFIG.blog.extensionBox.id]: {
    hide: true,
    selectorType: ElementSelectorType.Id,
    selector: '#blogExtensionBox',
    position: ElementSelectorPosition.BottomLeft,
  },
  [ELEMENT_IDENTIFIER_CONFIG.blog.articleInfoCard.id]: {
    hide: true,
    selectorType: ElementSelectorType.Class,
    selector: '.left-toolbox',
    position: ElementSelectorPosition.BottomCenter,
  },
  [ELEMENT_IDENTIFIER_CONFIG.blog.articleComment.id]: {
    hide: true,
    selectorType: ElementSelectorType.Id,
    selector: '#pcCommentBox',
    position: ElementSelectorPosition.BottomCenter,
  },
  [ELEMENT_IDENTIFIER_CONFIG.blog.recommendRead.id]: {
    hide: true,
    selectorType: ElementSelectorType.Class,
    selector: '.recommend-box',
    nameZh: '推荐文章',
    position: ElementSelectorPosition.BottomCenter,
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.copyright.id]: {
    hide: true,
    selectorType: ElementSelectorType.Id,
    selector: '#csdn-copyright-footer',
    position: ElementSelectorPosition.BottomCenter,
  },
  [ELEMENT_IDENTIFIER_CONFIG.default.loginModalTwo.id]: {
    hide: true,
    selectorType: ElementSelectorType.Class,
    selector: '.passport-login-tip-container',
    position: ElementSelectorPosition.BottomRight,
  },
  [ELEMENT_IDENTIFIER_CONFIG.ad.dynamicAd.id]: {
    show: false,
    hide: true,
    selectorType: ElementSelectorType.Attribute,
    selector: '[id^=\'dmp_ad_\']',
  },
}
